﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Entetities;

namespace DAL
{
    
    public class HinhAnhDAL
    {
        DataService db = new DataService();
        //public string loadhinh(int masp)
        //{
        //    string html = "";
        //    DataTable bang1 = db.layDulieu("select tenhinhlon as hinhlon from HinhAnh h1 join SP_HA h2 on h1.maHA=h2.maHA where maSP='"+masp+"'");
        //    html += "<div id='hinh_minh_hoa'><div id='hinh_lon'>";  
        //    if (bang1.Rows.Count > 0)
        //    {
        //        foreach (DataRow row in bang1.Rows)
        //        {
        //            html += "<img src='images1/" + row["hinhlon"] + ".jpg' />";
                       
        //        }
        //        html += "</div>";
        //    }

        //    DataTable bang2 = db.layDulieu("select tenhinhnho as hinhnho from HinhAnh h1 join SP_HA h2 on h1.maHA=h2.maHA where maSP='" + masp + "'");
            
        //    html += " <ul id='hinh_nho'>";
        //    int n = 0;
        //    if (bang1.Rows.Count > 0)
        //    {
        //        foreach (DataRow row1 in bang1.Rows)
        //        {
                    
        //            //if (n == 0)
        //            //{

        //            //    html += "<li class='active' rel='" + (n + 1) + "'><img  src='images1/" + row1[0] + ".jpg' /></li>";
        //            //    n++;
        //            //}
        //            //else
        //            //{
        //                html += "<li  rel='" + (n + 1) + "'><img  src='images1/" + row1[0] + ".jpg' /></li>";
        //                //n++;
        //            //}

        //        }
        //        html += "</ul></div>";
        //    }
        //    return html;

        //}
        public DataTable layhinh(int masp)
        {
            DataTable bang1 = db.layDulieu("select hinhkholon as hinhlon,hinhthunho as hinhnho  from HinhAnh h1 join SanPham_HinhAnh h2 on h1.Mahinhanh=h2.Mahinhanh where Masanpham='" + masp + "'");
            return bang1;
        }
       
    }
}
